﻿<view:SHViewBase x:Class="Mari.SmartHotel.Modules.Foundation.Guests.SearchGuestMainView" 
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:clabui="http://Microsoft.Services.Clab/ui/2010/07"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:local="clr-namespace:Mari.SmartHotel.Modules.Foundation.Guests"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:sys="clr-namespace:System;assembly=mscorlib"
                 xmlns:view="clr-namespace:Mari.SmartHotel.Core;assembly=Mari.SmartHotel.Core"
                 Title="Ricerca cliente"
                 d:DataContext="{d:DesignInstance Type=local:SearchGuestViewModel}"
                 d:DesignHeight="300"
                 d:DesignWidth="600"
                 mc:Ignorable="d">
    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <GroupBox Header="Criteri di ricerca">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Label Grid.Row="0" 
                       Width="Auto"
                       Height="Auto"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Center"
                       Content="Cognome:" />
                <TextBox Grid.Column="1" 
                         Grid.ColumnSpan="3"
                         HorizontalAlignment="Stretch"
                         VerticalAlignment="Center"
                         MaxLength="256"
                         Text="{Binding Path=SurnameGuest}">
                    <!--
                        <sh:ShellPanesService.HelpMessage>
                        <TextBlock TextWrapping="Wrap">Inserire il cognome del destinatario</TextBlock>
                        </sh:ShellPanesService.HelpMessage>
                    -->
                </TextBox>
                <Label Grid.Row="1" 
                       Width="Auto"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Center"
                       Content="Nome: " />
                <TextBox Grid.Row="1" 
                         Grid.Column="1"
                         Grid.ColumnSpan="3"
                         HorizontalAlignment="Stretch"
                         VerticalAlignment="Center"
                         MaxLength="256"
                         Text="{Binding Path=NameGuest}">
                    <!--
                        <sh:ShellPanesService.HelpMessage>
                        <TextBlock TextWrapping="Wrap">Inserire il nome del destinatario</TextBlock>
                        </sh:ShellPanesService.HelpMessage>
                    -->
                </TextBox>
                <Label Grid.Row="2" 
                       Grid.Column="0"
                       Width="Auto"
                       Height="Auto"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Center"
                       Content="Sesso:" />
                <ComboBox Grid.Row="2" 
                          Grid.Column="1"
                          Width="60"
                          HorizontalAlignment="Left"
                          DisplayMemberPath="GenderCode"
                          IsEditable="True"
                          ItemsSource="{Binding Path=Genders}"
                          SelectedValue="{Binding Path=GenderGuest}"
                          SelectedValuePath="GenderId" />
                <Label Grid.Row="3" 
                       Width="Auto"
                       Height="Auto"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Center"
                       Content="C.F.:" />
                <TextBox Grid.Row="3" 
                         Grid.Column="1"
                         Width="Auto"
                         HorizontalAlignment="Stretch"
                         VerticalAlignment="Center"
                         MaxLength="16"
                         Text="{Binding Path=CFGuest}" />
                <Label Grid.Row="3" 
                       Grid.Column="2"
                       Width="Auto"
                       Height="Auto"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Center"
                       Content="P.I.:" />
                <TextBox Grid.Row="3" 
                         Grid.Column="3"
                         Width="Auto"
                         HorizontalAlignment="Stretch"
                         VerticalAlignment="Center"
                         MaxLength="20"
                         Text="{Binding Path=PIGuest}" />
                <Label Grid.Row="2" 
                       Grid.Column="2"
                       Width="Auto"
                       Height="Auto"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Center"
                       Content="E-Mail:" />
                <TextBox Grid.Row="2" 
                         Grid.Column="3"
                         Width="Auto"
                         HorizontalAlignment="Stretch"
                         VerticalAlignment="Center"
                         Text="{Binding Path=EmailGuest}" />
                <Label Grid.Row="4" 
                       Width="Auto"
                       Height="Auto"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Center"
                       Content="Nome Società:" />
                <ComboBox Grid.Row="4" 
                          Grid.Column="1"
                          DisplayMemberPath="Name"
                          IsEditable="True"
                          ItemsSource="{Binding Path=Companies}"
                          SelectedItem="{Binding Path=Guest.Company}" />
                <StackPanel Grid.Row="5" 
                            Grid.ColumnSpan="4"
                            HorizontalAlignment="Right"
                            Orientation="Horizontal">
                    <Button Width="75" 
                            Margin="5"
                            Command="{clabui:ActionCommand ActionName=CleanFieldsSearchGuest}">
                        Pulisci campi
                    </Button>
                    <Button Width="75" 
                            Margin="5"
                            Command="{clabui:ActionCommand ActionName=SearchGuest}">
                        Cerca
                    </Button>
                </StackPanel>
            </Grid>
        </GroupBox>
        <GroupBox Grid.Row="1">
            <GroupBox.Header>
                <StackPanel Orientation="Horizontal">
                    <TextBlock>Risultato (</TextBlock>
                    <TextBlock FontWeight="Bold" Text="{Binding Path=TotalGuestsResult}"></TextBlock>
                    <TextBlock>)</TextBlock>
                </StackPanel>
            </GroupBox.Header>
            <DataGrid AutoGenerateColumns="False" 
                      IsReadOnly="True"
                      ItemsSource="{Binding Path=GuestListResult}">
                <DataGrid.Columns>
                    <DataGridTextColumn Width="*" 
                                        Binding="{Binding Path=Surname}"
                                        Header="Cognome" />
                    <DataGridTextColumn Binding="{Binding Path=Name}" Header="Name" />
                    <DataGridTextColumn Binding="{Binding Path=Gender.GenderCode}" Header="Sesso" />
                    <DataGridTextColumn Binding="{Binding Path=CF}" Header="CF" />
                    <DataGridTextColumn Binding="{Binding Path=PI}" Header="PI" />
                    <DataGridTemplateColumn Header="">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Image Width="16" Source="/Mari.SmartHotel.Controls;component/Resources/SHMessageBox/Information.png">
                                        <Image.ToolTip>
                                            <TextBlock Text="{Binding Path=Notes}" />
                                        </Image.ToolTip>
                                    </Image>
                                    <Button Command="{clabui:ActionCommand ActionName=EditGuest}" CommandParameter="{Binding}">
                                        <!--<Button.CommandParameter>
                                            <clabui:KeyValueCollection>
                                                <clabui:KeyValue Name="GuestId" Value="{Binding Path=GuestId}" />
                                            </clabui:KeyValueCollection>
                                        </Button.CommandParameter>-->
                                        <Image Width="16" Source="/Mari.SmartHotel.Controls;component/Resources/Ribbon/BusinessmanFind.png" />
                                    </Button>
                                </StackPanel>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>
        </GroupBox>
    </Grid>
</view:SHViewBase>
